package com.patterns.observer;

/**
 * 实现类
 * @author fwj
 * @date 2021/4/21 18:16
 **/
public class Client {

    public static void main(String[] args) {
        Editor editor = new Editor();
        editor.events.subscribe("open", new LogListener("/path/to/log/file.txt"));
        editor.events.subscribe("save", new EmailNotifyListener("admin@example.com"));

        try {
            editor.openFile("test.txt");
            editor.saveFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
